package com.leetcode.LC;

public class LC1221 {
    public int balancedStringSplit(String s) {
        //思路：两个变量分别记录R和L的个数，如果个数相同做个标记，然后直接计数
        int a=0,b=0,count=0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i)=='R'){
                a++;
            }else {
                b++;
            }

            if (a==b){
                count++;
            }
        }

        return count;
    }

    public static void main(String[] args) {
        System.out.println(new LC1221().balancedStringSplit("LLLLRRRR"));
    }
}
